<template>
  <div v-if="userInfo">
    <span slot="header">昵称：{{ userInfo.userName }}</span>
    <el-divider :class="dividerStyle"></el-divider>
    <div>
      <p>编号：{{ userInfo.userId }}</p>
      <el-divider :class="dividerStyle"></el-divider>
      <p>邮箱：{{ userInfo.email }}</p>
    </div>
  </div>
  <p v-else>正在加载数据</p>
</template>

<script>
export default {
  name: 'UserInfo',
  props: {
    menuDivider: Boolean,
    userInfo: [Object]
  },
  computed: {
    dividerStyle () {
      return this.menuDivider ? 'menu-divider' : 'default-divider'
    }
  },
  watch: {
    userInfo: {
      handler (newVal, oldVal) {
        this.userInfo = newVal
      }
    }
  }
}
</script>

<style lang="scss" scoped>
.el-card {
  border: 0;
}
.default-divider {
  margin: 24px 0;
}
.menu-divider {
  margin: 8px 0;
}
</style>
